package hot;

import java.util.ArrayList;
import java.util.List;

public class shiqi {
    class Solution {
        String[] hash={"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
        List<String> ret=new ArrayList<>();
        StringBuffer path=new StringBuffer();
        public List<String> letterCombinations(String digits) {
            dfs(digits,0);
            return ret;
        }
        public void dfs(String digits,int pos){
            if(pos==digits.length()){
                ret.add(String.valueOf(path));
                return;
            }
            //获取pos对应的字符串
            String curstring=hash[digits.charAt(pos)-'0'];
            for(int i=0;i<curstring.length();i++){
                path.append(curstring.charAt(i));
                dfs(digits,pos+1);
                //回溯恢复现场
                path.deleteCharAt(path.length()-1);
            }

        }
    }
}
